use "JLC_citationsdata.dta"

***** LOGGED DV
gen SC_DV=SC_incites+SC_pos+SC_neut
gen CA_DV=CA_incites+CA_pos+CA_neut
gen DC_DV=DC_incites+DC_pos+DC_neut
gen log_SC=log(SC_DV+1)
gen log_CA=log(CA_DV+1)
gen log_DC=log(DC_DV+1)

*TABLE 4: 
eststo clear
xtgee log_SC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
gen fullmodelsample=e(sample)
eststo: xtgee
xtgee log_CA i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 

*TABLE 5: 
eststo clear
xtgee log_SC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_CA i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust) 
eststo: xtgee
xtgee log_SC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_con SC_decision_lib##disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_CA i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_con SC_decision_lib##disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_con SC_decision_lib##disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 

*FIGURE 2:
gen m4= (majVotes==4)
gen m5= (majVotes==5)
gen m6= (majVotes==6)
gen m7= (majVotes==7)
gen m8= (majVotes==8)
gen m9= (majVotes==9)
graph bar m4 m5 m6 m7 m8 m9 if SC_decision_con==1 & fullmodelsample==1 & age2==1, ascategory ytitle("Proportion of Conservative Decisions") title("Majority Size of Conservative Decisions") ysc(r(0, .4)) ylabel(0(.1).4)
graph bar m4 m5 m6 m7 m8 m9 if SC_decision_lib==1 & fullmodelsample==1 & age2==1, ascategory ytitle("Proportion of Liberal Decisions") title("Majority Size of Liberal Decisions") 

*TABLE 6:  
eststo clear
xtgee log_CA i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol CAalign disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol DCalign disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 

*TABLE 7:
eststo clear
xtgee log_DC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol CAalign disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 
